/*
 * acm1159.c
 *
 *  Created on: 4 Apr 2010
 *      Author: xuxu
 */

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int getnumber(char *str)
{
	int len;
	int i;
	int result;
	len=strlen(str);
	result=0;
	for(i=0;i<len;i++)
	{
		if(str[i]>='0'&&str[i]<='9')
			result=result*10+str[i]-'0';
		else if(str[i]>='A'&&str[i]<='C')
			result=result*10+2;
		else if(str[i]>='D'&&str[i]<='F')
			result=result*10+3;
		else if(str[i]>='G'&&str[i]<='I')
			result=result*10+4;
		else if(str[i]>='J'&&str[i]<='L')
			result=result*10+5;
		else if(str[i]>='M'&&str[i]<='O')
			result=result*10+6;
		else if(str[i]=='P'||str[i]=='R'||str[i]=='S')
			result=result*10+7;
		else if(str[i]>='T'&&str[i]<='V')
			result=result*10+8;
		else if(str[i]>='W'&&str[i]<='Y')
			result=result*10+9;
	}
	return result;
}

int cmp ( const void *a , const void *b )
{
     return *(int *)a-*(int *)b;
}

int main()
{
	int count,n;
	int number[100001],con;
	char tel[50];
	int bo;
	int i;
	scanf("%d",&count);
	while(count--)
	{
		con=0;
		memset(number,0,sizeof(number));
		scanf("%d",&n);
		while(n--)
		{
			scanf("%s",tel);
			number[con++]=getnumber(tel);
		}
		bo=0;
		n=con;
		qsort(number,n,sizeof(number[0]),cmp);
		for(i=0;i<n-1;i++)
		{
			if(number[i]==number[i+1])
			{
				bo=1;
				i++;
				con=2;
				while(number[i]==number[i+1]&&i<n-1)
				{
					i++;
					con++;
				}
				printf("%03d-%04d %d\n",number[i]/10000,number[i]%10000,con);
			}
		}


		if(!bo)
			printf("No duplicates.\n");
		if(count)
			printf("\n");
	}
	return 0;
}
